{fx_template 'common/header'}
<link href="{FX_URL}web/resource/css/util.min.css" rel="stylesheet">
<script type="text/javascript" src="{FX_URL}web/resource/js/util.min.js?v=20170912"></script>
<style>
thead{background-color: #f4f5f9;}
</style>
<ul class="nav nav-tabs">
	<li {if $op=='display'}class="active"{/if}><a href="{php echo web_url('member/member/display')}">会员</a></li>
	{if !empty($uid)}
	<li {if $op=='credit_record' && $type=='credit1'}class="active"{/if}><a href="{php echo web_url('member/member/credit_record',array('type'=>'credit1','uid'=>$uid))}">积分</a></li>
	<li {if $op=='credit_record' && $type=='credit2'}class="active"{/if}><a href="{php echo web_url('member/member/credit_record',array('type'=>'credit2','uid'=>$uid))}">余额</a></li>
	{/if}
</ul>
{if $op=='display'}
<div class="panel panel-default">
	<div class="panel-heading">筛选</div>
	<div class="panel-body">
		<form action="./index.php" method="get" class="form-horizontal" role="form" id="form">
			<input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="{MODULE_NAME}" />
            <input type="hidden" name="do" value="member" />
			<input type="hidden" name="ac" value="member" />
			<input type="hidden" name="op" value="display" />
			<input type="hidden" name="status" value="{$_GPC['status']}">
			<div class="form-group">
				<label class="col-md-2 control-label">关键字类型</label>
				<div class="col-sm-8 col-xs-12">
					<select name="type" class="form-control">
						<option value="2" {if $_GPC['type'] == 2}selected{/if}>手机号</option>
						<option value="4" {if $_GPC['type'] == 4}selected{/if}>真实姓名</option>
						<option value="3" {if $_GPC['type'] == 3}selected{/if}>昵称</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">关键字</label>
				<div class="col-md-8">
					<input type="text" class="form-control" name="keyword" id="keyword" value="{$_GPC['keyword']}" />
				</div>
				<div class="pull-right col-md-2">
					<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
				</div>
			</div>
		</form>
	</div>
</div>
<div class="panel panel-default">
	<div class="table-responsive">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:80px;">Uid</th>
					<th>手机</th>
					<th style="width:100px;">真实姓名</th>
					<th style="width:150px;">昵称</th>
					<th style="width:100px;">积分</th>
					<th style="width:100px;">余额</th>
					<th style="width:180px;" class="text-center">操作</th>
				</tr>
			</thead>
			<tbody>
			{loop $list $li}
				<tr id="{$li['uid']}">
					<td>{$li['uid']}</td>
					<td>{$li['mobile']}</td>
					<td>{$li['realname']}</td>
					<td>{$li['nickname']}</td>
					<td id="credit1{$li['uid']}">{$li['credit1']}</td>
					<td id="credit2{$li['uid']}">{$li['credit2']}</td>
					<td style="overflow:visible;">
                        <div class="btn-group">
                            <div class="btn-group">
                                <button type="button" class="btn btn-default{php echo $li['blacklist']?' btn-danger':'';} dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><font>{php echo $li['blacklist']?'黑名单 ':'白名单 ';}</font><span class="caret"></span></button>
                                <ul class="dropdown-menu" id="menu_{$li['uid']}">
                                    <li class="user-blacklist" data-uid="{$li['uid']}" data-blacklist="{php echo $li['blacklist']?0:1;}"><a href="javascript:;">{php echo $li['blacklist']?'白名单':'黑名单';}</a></li>
                                </ul>
                            </div>
                            <a href="{php echo web_url('member/member/credit_record', array('uid' => $li['uid']))}" class="btn btn-success">日志</a>
                        </div>
                        <a href="javascript:;" class="btn btn-default js-recharge" uid="{$li['uid']}" title="充值" style="display:none">充值</a>
					</td>
				</tr>
			{/loop}
			</tbody>
		</table>
	</div>
</div>
{$pager}
<div id="modal-message" class="modal fade" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">	<h4>会员操作<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button></h4></div><div class="modal-body"><style>
	.table{margin-bottom: 0}
	.table td, .table th{text-align: center}
</style>
<form class="table-responsive" method="post" action="./index.php?c=mc&amp;a=creditmanage&amp;do=manage&amp;" id="form1">
	<input type="hidden" name="do" value="manage">
	<input type="hidden" name="uid" value="">
	<input name="token" type="hidden" value="db754d26">
	<table class="table table-hover table-bordered">
		<tbody>
			<tr>
				<th>积分</th>
				<td>
					<label class="radio-inline"><input type="radio" name="credit1_type" value="1" checked=""> 增加</label>
					<label class="radio-inline"><input type="radio" name="credit1_type" value="2"> 减少</label>
				</td>
				<td>
					<input type="text" name="credit1_value" value="0" class="form-control">
				</td>
			</tr>
			<tr>
				<th>余额</th>
				<td>
					<label class="radio-inline"><input type="radio" name="credit2_type" value="1" checked=""> 增加</label>
					<label class="radio-inline"><input type="radio" name="credit2_type" value="2"> 减少</label>
				</td>
				<td>
					<input type="text" name="credit2_value" value="0" class="form-control">
				</td>
			</tr>
			<tr>
				<th>积分操作备注</th>
				<td colspan="3">
					<textarea class="form-control" name="remark"></textarea>
				</td>
			</tr>
		</tbody>
	</table>
</form>
<div class="modal-footer">
	<span name="submit" id="submit" class="pull-right btn btn-primary" uid="" data-dismiss="modal" aria-hidden="true">保存</span>
</div>
</div></div></div></div>
{elseif $op=='credit_record'}
<div class="alert alert-info">
	<div class="form-horizontal">
		<div class="form-group">
			<label class="col-md-1 control-label">uid：</label>
			<div class="col-sm-2">
				<p class="form-control-static">{$member['uid']}</p>
			</div>
			<label class="col-md-1 control-label">昵称：</label>
			<div class="col-sm-5">
				<p class="form-control-static">{if $member['nickname']}{$member['nickname']}{else}-{/if}</p>
			</div>
		</div>
		<div class="form-group">
			<label class="col-md-1 control-label">手机：</label>
			<div class="col-sm-2">
				<p class="form-control-static">{if $member['mobile']}{$member['mobile']}{else}-{/if}</p>
			</div>
			<label class="col-md-1 control-label">姓名：</label>
			<div class="col-sm-5">
				<p class="form-control-static">{if $member['realname']}{$member['realname']}{else}-{/if}</p>
			</div>
		</div>
	</div>
</div>
<style>
	table thead tr th {text-align: center;}
	table tbody tr td {text-align: center; height: 50px;}
	table tbody tr td:last-child {text-align: center;}
</style>
<div class="panel panel-default">
	<div class=" panel-body table-responsive">
		<table class="table table-hover">
			<thead>
				<tr>
					<th style="width:20%;">类型</th>
					<th style="width:20%;">数目</th>
					<th style="width:20%;">操作时间</th>
					<th style="width:30%;">备注</th>
				</tr>
			</thead>
			<tbody>
				{loop $credits_records $row}
					<tr>
						<td>{if $row['uid']==$row['operator']}用户操作{else}系统操作{/if}</td>
						<td>{$row['num']}</td>
						<td>{php echo date('Y-m-d H:i:s', $row['createtime'])}</td>	
						<td>{$row['remark']}</td>
					</tr>
				{/loop}
			</tbody>
		</table>
	</div>
</div>
{$pager}
{/if}
<script>
	$(function(){
		$('.user-blacklist').click(function(e){
			e.stopPropagation();
			var $this = $(this),uid = $this.data('uid'),blacklist=parseInt($this.attr('data-blacklist'));
			if (blacklist) {
				html = '确认加入黑名单?';
			}else{
				html = '确认加入白名单?';
			}
			util.nailConfirm(this, function(state) {
				$this.parents('.btn-group').trigger('click');
				if(!state) return;
				$.post("{php echo web_url('member/member/blacklist')}", {uid:uid,blacklist:blacklist}, function(data){
					if(!data.errno){
						$this.attr('data-blacklist',blacklist?0:1);
						$this.find('a').html(blacklist?'白名单':'黑名单');
						$this.parents('.btn-group').find('font').html(blacklist?'黑名单 ':'白名单 ');
						$this.parents('.btn-group').find('button').toggleClass('btn-danger');  
						util.tips(data.message);
					};
				}, 'json');
			}, {html:html,placement: 'left'});
		});
		$('.js-recharge').click(function() {
			var uid = $(this).attr('uid');
			if(uid==''){util.tips("非关注会员不能充值!!");return false;}
			$('#submit').attr("uid",uid);
			//$('#modal-message').show();
			popwin = $('#modal-message').modal();
		});
		$('.close').click(function() {
			$('#modal-message').hide();
			$('.panel').css("opacity","1");$('.nav').css("opacity","1");$('.pagination').css("opacity","1");
		});
		$('#submit').click(function() {
			var uid = $(this).attr('uid');
			var credit1_type = $("input[name='credit1_type']:checked").val();
			var credit1_value = $("input[name='credit1_value']").val();
			var credit2_type = $("input[name='credit2_type']:checked").val();
			var credit2_value = $("input[name='credit2_value']").val();
			var remark = $("textarea[name='remark']").val();
			$.post("{php echo web_url('member/member/modal')}",{remark:remark,uid:uid,credit1_type:credit1_type,credit1_value:credit1_value,credit2_type:credit2_type,credit2_value:credit2_value},function(d){
				if(!d.errno){
					$('#credit1'+uid).html(d.credit1);
					$('#credit2'+uid).html(d.credit2);
				}
				util.tips(d.message);
			},"json");
		});
		
	});
</script>
{fx_template 'common/footer'}